package com.wyf.controller;

import com.wyf.exceptions.BusinessException;
import com.wyf.exceptions.ParamsException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController extends BaseController { // 通过继承异常处理类，处理可能出现的异常

    @GetMapping("/hello")
    @ResponseBody
    public String hello() {
        // 设置异常
        //int a = 1 / 0;

        // 设置自定义异常
        if (true) {
            //throw new ParamsException();
            throw new BusinessException();
        }
        return "hello";
    }
}
